﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<SeaBattle.UI.Web.Models.ChildActions.GameListViewModel>" %>

<% if (Model.Games.Count() != 0)
   { %>
<h4>Current games:</h4>
<table cellspacing="0">
<thead>
<td>#</td>
<td>Opponent</td>
<td>Preset</td>
</thead>
<% foreach (var game in Model.Games)
   {%>
<tr>
 <td><%: Html.ActionLink(game.Id.ToString(), "Index", "Game", new { id = game.Id }, new { })%> </td>
 <td><%: game.Creator.Login == Model.UserLogin ? game.Opponent.Name : game.Creator.Name%></td>
 <td><%: game.Preset%></td>
     </tr>     
    <%}%>
    </table>
<%}%>


<% if (Model.NotOpenedGamesList.Count() != 0)
   { %>
    <h4>Your not opened games:</h4>
    <table cellspacing="0">
        <thead>
            <td>#</td>
            <td>Preset</td>
            <td></td>
        </thead>
    <% foreach (var game in Model.NotOpenedGamesList)
        {%>        
        <tr>            
            <td><%: game.Id.ToString()%> </td>
            <td><%: game.Preset%></td>
            <td>
                <span id="delete-panel-<%:game.Id.ToString()%>">
                <%= Ajax.ActionLink("Delete game", "Delete", "Room", new { GameID = game.Id },
                     new AjaxOptions { UpdateTargetId = "delete-panel-" + game.Id.ToString() }) %>
                </span>
            </td>
        </tr>     
        <%}%>
    </table>
<%}%> 